package ru.stepanovdn.trading.loader.entity

import jakarta.persistence.*
import java.math.BigDecimal
import java.math.BigInteger
import java.time.LocalDateTime

/**
 * https://tinkoff.github.io/investAPI/instruments/#share
 */

@Entity
@Table(
    name = "share",
    indexes = [
        Index(columnList = "isin"), Index(columnList = "figi"),
        Index(columnList = "ticker, class_code", unique = true)
    ]
)
class Share(

    @Id
    @Column(name = "isin", nullable = false, updatable = false, unique = true, length = 12)
    var isin: String,

    @Column(name = "figi", nullable = false, length = 12)
    var figi: String,

    @Column(name = "ticker", nullable = false, length = 5)
    var ticker: String,

    @Column(name = "class_code", nullable = false, length = 5)
    var classCode: String,

    @Column(name = "lot", nullable = false)
    var lot: Int,

    @Column(name = "currency", nullable = false, length = 3)
    var currency: String,

    @Column(name = "exchange", nullable = false, length = 32)
    var exchange: String,

    @Column(name = "sector", nullable = false, length = 32)
    var sector: String,

    @Column(name = "api_trade_available_flag", nullable = false)
    var apiTradeAvailableFlag: Boolean,

    @Column(name = "for_qual_investor_flag", nullable = false)
    var forQualInvestorFlag: Boolean,

    @Column(name = "buy_available_flag", nullable = false)
    var buyAvailableFlag: Boolean,

    @Column(name = "sell_available_flag", nullable = false)
    var sellAvailableFlag: Boolean,

    @Column(name = "weekend_flag", nullable = false)
    var weekendFlag: Boolean,

    @Column(name = "liquidity_flag", nullable = false)
    var liquidityFlag: Boolean,

    @Column(name = "nominal_unit", nullable = false)
    var nominalUnit: Long,

    @Column(name = "nominal_nano", nullable = false)
    var nominalNano: Int,

    @Column(name = "min_price_increment_unit", nullable = false)
    var minPriceIncrementUnit: Long,

    @Column(name = "min_price_increment_nano", nullable = false)
    var minPriceIncrementNano: Int,

    @Column(name = "first_1min_candle_date", nullable = false, columnDefinition = "DATE")
    var first1minCandleDate: LocalDateTime,

    @Column(name = "first_1day_candle_date", nullable = false)
    var first1dayCandleDate: LocalDateTime

) {
    @Column(name = "name", nullable = true)
    var name: String? = null
}
